<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <!-- START 右侧数据 -->
            <div class="ibox float-e-margins" style="margin-bottom: 0px;">
                <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                    <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                        <div class="form-group">
                            <label class="control-label col-sm-1" >SKU:</label>
                            <div class="col-sm-2">
                                <input type="text" id="designSku" name="designSku" placeholder="请输入SKU" class="form-control">
                            </div>
                            <label class="control-label col-sm-1" >活动状态:</label>
                            <div class="col-sm-2">
                                <select  name="designStatus" id="designStatus" class="form-control">
                                    <option value="">全部分类</option>
                                    <option value="1">未开始</option>
                                    <option value="2">进行中</option>
                                    <option value="3">已完成</option>
                                    <option value="4">已取消</option>
                                </select>
                            </div>
                            <label class="control-label col-sm-1" >商品属性:</label>
                            <div class="col-sm-2">
                                <select id="designProductProperty" name="designProductProperty" class="form-control">
                                    <option value="">全部属性</option>
                                    <option value="上新">上新</option>
                                    <option value="优化">优化</option>
                                </select>
                            </div>
                            <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                        </div>

                    </form>
                </div>
            </div>
            <!-- START 操作按钮 -->
            <form>
            <div id="toolbar" class="btn-group" >
                <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 新增需求</a>
                <!--<a class="del-btn btn btn-sm btn-danger"><i class="fa fa-trash" aria-hidden="true"></i> 删除</a>-->
            </div>
            </form>
            <!-- END 操作按钮 -->

            <!-- START 数据表格 -->
            <table id="relatedTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-url="/sea/design/findByCnd.do"
                   data-page-size="15"
                   class="table table-striped table-hover"
                   >
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer'}){}%>
<script>
    var $relatedTable = $('#relatedTable'),selections=[];
    $(function(){
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: '渠道',
                    field: 'designChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'SKU',
                    field: 'designSku',
                    align: 'center',
                    valign: 'middle'
                },{
                    title: '商品属性',
                    field: 'designProductProperty',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '产品名称',
                    field: 'productName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '简单描述要求',
                    field: 'designDescription',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '参考图',
                    field: 'designPic',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(null!=v && v!=''){
                            var result='<button  class="download-sku-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result+='<i class="fa fa-download" aria-hidden="true"></i> <a href="'+v+'" download style="color: white">下载参考图</a>';
                            result+='</button>';
                            return result;
                        }
                    }
                },
                {
                    title: '提出时间',
                    field: 'createTime',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        var  result=v;
                        if(v==null){
                            return '';
                        }
                        if(null!=v && v.length>10){
                            v=v.substr(0,10);
                        }
                        return v;
                    }
                },
                {
                    title: '提出人',
                    field: 'designMember',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预计完成时间(运营)',
                    field: 'designExpectNew',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '实际完成时间(设计)',
                    field: 'designComplete',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '附件',
                    field: 'designAttachment',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(null!=v && v!=''){
                            var result='<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result+='<i class="fa fa-download" aria-hidden="true"></i> <a href="'+v+'" download style="color: white">下载附件</a>';
                            result+='</button>';
                            return result;
                        }else{
                            return '';
                        }
                    }
                },
                {
                    title: '状态',
                    field: 'designStatus',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(v=='1'){
                            return '未开始'
                        }else if(v=='2'){
                            return '进行中'
                        }else if(v=='3'){
                            return '已完成'
                        }else if(v=='4'){
                            return '已取消'
                        }else {
                            return '未知'
                        }
                    }
                },
                {
                    title: '备注',
                    field: 'designRemark',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
//删除
                //删除数据字典详情信息
                $('.del-btn').on('click',function(){
                    var delid = $(this).attr('data-val'),delname = $(this).attr('data-val-name');
                    //删除提示
                    layer.confirm('确定要删除当前数据？', {
                        btn: ['确定','取消'],title:'提示'
                    }, function(){
                        $.post('/sea/design/delete.do',{id: delid},function(data){
                            if( data.ok ){
                                layer.msg(data.msg,{icon: 1,time: 1500},function(){
                                    //刷新页面
                                    $relatedTable.bootstrapTable('refresh');
                                });
                            }else{
                                layer.msg(data.msg,{icon: 0,time: 1500});
                            }
                        });
                    });
                });
            }
        });
        //END 表格配置
        //表格高度自适应
//        $(window).resize(function () {
//            $dealTable.bootstrapTable('resetView', {
//                height: getHeight()
//            });
//        });
    });
    //操作菜单
    function optFormatter(value,row){
        if(row.designStatus==3 || row.designStatus==4){
            return '';
        }else{
            var content = '<button class="del-btn btn btn-xs btn-danger" data-val="'+row.id+'" title="删除"><i class="fa fa-trash-o"></i>  </button>';
            return content;
        }
    }




    //新增
    $('.add-btn').on('click',function(){//新增
        layer.open({
            title: false,
            closeBtn: 0,
            type: 2,
            area: ['100%','100%'],
            skin: 'layer-ext-espresso',
            content: ['/sea/design/addPage.do', 'yes']
        });
    });

    $('.search-btn').on('click',function(){
           $relatedTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/design/findByCnd.do?'+$('#search-form').serialize() });
    });

</script>
</body>
</html>
